/**
 *
 *
 * @Description:
 * @Author: zhangzhengwei2006
 * @Date: 2024-01-17 12:03
 *
 *
 */


import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 线程等待；自定义类实现java.lang.Runnable接口
 */
public class ThreadTask1 {
    public static void main(String[] args) {
        //自定义类实现java.lang.Runnable接口
//        MyRunnable runnable = new MyRunnable();
//        MyRunnableUtils runnable = new MyRunnableUtils();
        //创建线程(自定义类MyRunnable实现java.lang.Runnable接口)
//        Thread t = new Thread(runnable);
        //开启线程
//        t.start();
    }
}

/**
 * 自定义类MyRunnable实现java.lang.Runnable接口
 */
class MyRunnable implements Runnable{
    final long timeInterval = 1000*10;

    @Override
    public void run() {
        while (true){
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
            String dateStr = sdf.format(new Date());
            System.out.println("线程等待实现定时任务1：" + dateStr);

            try {
                Thread.sleep(timeInterval);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}